#include "journeymodels.h"
#include "QDebug"

int FlightJourney::getTotalTime() const {
    if (segments.isEmpty()) {
        return 0;
    }

    // 获取旅程的开始和结束时间
    QTime journeyStartTime = segments.first().departureTime;
    QTime journeyEndTime = segments.last().arrivalTime;

    // 计算从开始到结束的总分钟数
    int totalMinutes = journeyStartTime.secsTo(journeyEndTime) / 60;

    return totalMinutes;
}

double FlightJourney::getTotalPrice() const{
    qDebug() << "Segment count:" << segments.size();
    for (const FlightSegment &segment : segments) {
        qDebug() << "Segment price:" << segment.price;
    }
    double total = 0.0;
            for (const FlightSegment &segment : segments) {
                total += segment.price;            // 加上每段的票价
                //total += segment.servicePrice;     // 加上每段的服务价格
            }
            return total;
}

int FlightJourney::getTotalHours(int t) const{
    int hours = t / 60;

    return hours;
}

int FlightJourney::getTotalMinutes(int t) const{
    int minutes = t % 60;

    return minutes;
}
